/**
 * calculate average and then set to the field
 * 
 * @param btn
 * @param evt
 * @return
 */
function updateOverallMark(btn, evt) {
	console.log("update average at " + (new Date()).toString());
	var multiField = CQ.Ext.getCmp('multifield-marklist-1');
	var children = multiField.findByType('markfield');
	var totalMark = 0;
	var totalRate = 0;
	var subjectMark;
	var rate;
	for ( var i = 0; i < children.length; i++) {
		subjectMark = children[i].findByType('numberfield')[0].getValue();
		rate = children[i].findByType('spinner')[0].getValue();
		totalMark += subjectMark * rate;
		totalRate += rate * 1;// short way to parse 'rate' to number
		console.log("mark " + totalMark + ", rate " + totalRate);
	}

	var markCmp = CQ.Ext.getCmp('textfield-medium-mark-1');
	if (totalRate > 0) {
		markCmp.setRawValue((totalMark / totalRate).toFixed(2));
	} else {
		markCmp.setRawValue('');
	}
}

function doLayoutPanel(pnl) {
	pnl.doLayout(false, true);
	console.log("activate panel '" + pnl.title + "'");
}